package com.yswl.yeeduo.ui.db;


import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public abstract class BaseDao {

	protected void closeDatabase(SQLiteDatabase __db) {
		try {
			if (__db != null && __db.isOpen()) {
				__db.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


	protected void closeCursor(Cursor __cursor) {
		try {
			if (__cursor != null && __cursor.isClosed() == false) {
				__cursor.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected SQLiteDatabase getDatabase(boolean __isWriteable) {
		if (__isWriteable) {
 			return new DBManager().getWritableDatabase();
		} else {
			return new DBManager().getReadableDatabase();
		}
	}
}
